package com.qjq.glasses_shopping.result;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

/*
    统一结果返回集
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class BaseResult<T> implements Serializable {
    //状态码
    private Integer code;
    //状态信息
    private String message;
    //返回数据
    private T data;

    //普通返回不携带数据
    public static <T> BaseResult<T> ok(){
        return new BaseResult(CodeEnum.SUCCESS.getCode(),CodeEnum.SUCCESS.getMsg(),null);
    }

    //携带数据返回
    public static <T> BaseResult<T> ok(T data){
        return new BaseResult(CodeEnum.SUCCESS.getCode(),CodeEnum.SUCCESS.getMsg(),data);
    }
}
